<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    let set = new Set([1, 2, 2, 4, 5, 67, 8, 98, 8])
    console.log(set)
    //利用数组给数组去重
    let arr = [1, 2, 3, 2, 2, 24, 5, 6, 3, 4, 5, 66, 7, 8]
    let arrset = new Set([...arr])
    console.log(arrset)
    //并集
    let arr1 = [1, 2, 3, 4]
    let arr2 = [3, 4, 5, 6, 7]
    let arrset1 = new Set([...arr1, ...arr2])
    console.log(arrset1)
    //交集
    let arrset2 = [...new Set(arr1)].filter(item => new Set(arr2).has(item))
    console.log(arrset2)
    //差集
    let arrset3 = [...new Set(arr1)].filter(item => !(new Set(arr2).has(item)))
    console.log(arrset3)
  </script>
</head>

<body>

</body>

</html>